<?php 
header("Content-type: text/html; charset=utf-8");
session_start();
// var_dump($_SESSION['username']);
// 		exit();
// 判断是否post
if($_GET){
	$db = include './db.php';
	foreach ($db as $key => $value) {
		if($key==$_GET['id']){
			if($_SESSION['username']==$db[$key]["name"]){
				unset($db[$key]);
				$newDb = var_export($db,TRUE);
				$newDb2 ="<?php  return $newDb ?>";
				file_put_contents('./db.php',$newDb2);

				$message = "删除成功";

		        include './tpl/success.html';
			}else{
				$error = "您没有权限删除别人的留言";
				include './tpl/error.html';
                 }
			
			}
		}
	

}else{
	// 非POST,跳转回首页
	// 引入错误页面
	$error = "删除失败";
 	include './tpl/error.html';
}


 ?>

